﻿#pragma once
#include <memory>
#include <functional>
#include "as_socket.h"
#include "base_type.h"

class ByteBuffer;
DEFINE_PTR(ByteBuffer)
namespace as
{
	namespace md
	{
		struct MailPos;
	}

	namespace net
	{
		class TcpConnection;
		typedef std::shared_ptr<TcpConnection> TcpConnectionPtr;
		typedef std::function<void(socket_fd, Address&)> NewConnCb;
		typedef std::function<void(const TcpConnectionPtr&)> ConnChangeCb;
		typedef std::function<void(const TcpConnectionPtr&)> CloseCallback;
		typedef std::function<void(const TcpConnectionPtr&, int)> ErrCallback;
		typedef std::function<void(const TcpConnectionPtr&)> WriteCompleteCallback;
		typedef std::function<void(TcpConnectionPtr&, ByteBufferPtr&, int)> MsgCallback;
	}
}


typedef std::function<void(ByteBufferPtr&, as::md::MailPos&)> ActorMsgCallFun;

//ÏûÏ¢°ó¶¨
#define MSG_BIND_FUNCTION(MSG_NAME, cbFun)																\
	cb_fun_[MSG_NAME] = std::bind(cbFun, this, std::placeholders::_1, std::placeholders::_2);

